﻿namespace Sage.DownloadLite.Models
{
    /// <summary>
    /// 下载任务信息
    /// </summary>
    public class TaskInfo
    {
        /// <summary>
        /// 任务唯一标识
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 下载URL
        /// </summary>
        public string Url { get; set; } = string.Empty;
        /// <summary>
        /// 保存文件路径
        /// </summary>
        public string FilePath { get; set; } = string.Empty;
        /// <summary>
        /// 文件名，从FilePath中提取
        /// </summary>
        public string FileName => Path.GetFileName(FilePath);
        /// <summary>
        /// 任务状态
        /// </summary>
        public Enums.TaskStatus Status { get; set; } = Enums.TaskStatus.Waiting;
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; } = DateTime.Now;
        /// <summary>
        /// 用户自定义数据，可用于存储额外信息
        /// </summary>
        public object? UserData { get; set; }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="id">任务ID</param>
        /// <param name="url">下载URL</param>
        /// <param name="filePath">保存文件路径</param>
        public TaskInfo(int id, string url, string filePath)
        {
            Id = id;
            Url = url ?? throw new ArgumentNullException(nameof(url));
            FilePath = filePath ?? throw new ArgumentNullException(nameof(filePath));
        }
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public TaskInfo() { }
    }
}
